#!/bin/sh -efu

mkdir -p /boot

vmlinuz="$(find /boot -type f -name 'vmlinuz-*')"
kversion="${vmlinuz##/boot/vmlinuz-}"

[ -n "$GLOBAL_DTB_NAME" ]

DTB_FILE="/lib/devicetree/$kversion/$GLOBAL_DTB_NAME"
DTB_NAME="$(basename "$DTB_FILE" .dtb)"

cp "$DTB_FILE" "/boot/$DTB_NAME-$kversion.dtb"
ln -s "$DTB_NAME-$kversion.dtb" "/boot/$DTB_NAME.dtb"

# various SDK version have various defaults
ln -s boot/vmlinuz /vmlinux.bin
ln -s boot/vmlinuz /bfk3.vmlinux.bin
ln -s boot/initrd.img /initramfs.gz
ln -s "boot/$DTB_NAME.dtb" /baikal.dtb
ln -s "boot/$DTB_NAME.dtb" /bfk3.dtb

exit 0
